
	$(function (){
		// alert(1);
		var info=document.getElementById('nmsg');
		var rpwinfo=document.getElementById('rpwinfo');
		var codeinfo=document.getElementById('codeinfo');
		$('input[name="username"]').blur(function (){
			// alert(1);
    		$.post(rg, {username : $('input[name="username"]').val()} , 
          		function (data) {
    				if (data.status) {
              			info.innerHTML=data.msg;
    				} else {
    					info.innerHTML=data.msg;
    				}
    			}, "json");
      	});

		$('input[name="rpassword"]').blur(function (){
			if($('input[name="password"]').val()!=$('input[name="rpassword"]').val()){
				rpwinfo.innerHTML="<span style='color:red; margin-left:0'>两次密码不一致</span>";
			}else{
				rpwinfo.innerHTML='密码格式正确';
			}
      	});

		$('#icd').click(function (){
			$(this).attr('src', sc+Math.random());
		});

		$('#change').click(function (){
			$('#icd').attr('src', sc+Math.random());
		});

		$('input[name="code"]').blur(function(){
	        $.post(cc,{verify :$('input[name="code"]').val()},
	          function (data){
	            if(!data.status){
	              codeinfo.innerHTML=data.msg;
	            }else{
	              codeinfo.innerHTML=data.msg;
	            }
	          },"json");
      	});

		$('#regnow').click(function (){
			if($('input[name="regusername"]').val()==''){
				alert('用户名不能为空');
				return false;
			}else if(info.innerHTML=='<span style="color:red; margin-left:0">用户名已存在</span>'){
				alert('用户名已存在');
				return false;
			}else if($('input[name="regpassword"]').val()!=$('input[name="regpassword2"]').val()){
				alert('两次密码不一致');
				return false;
			}else if(codeinfo.innerHTML=='<span style="color:red; margin-left:0">验证码错误 </span>'){
				alert('验证码错误');
				return false;
			}
		});
	});